//
//  HYMVHeaderView.m
//  TTLestening
//
//  Created by dllo on 16/3/30.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "HYMVHeaderView.h"
#import "XCModelForMVHeader.h"

#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>

@interface HYMVHeaderView ()

@property (nonatomic, strong) UIButton *buttonForDowLod;
@property (nonatomic, strong) UILabel *labelForName;
@property (nonatomic, strong) UILabel *labelForPlayCount;
@property (nonatomic, strong) UILabel *labelForCommentCount;
@property (nonatomic, strong) UIImageView *imageViewForPlay;
@property (nonatomic, strong) UIImageView *imageViewForComment;

@end

@implementation HYMVHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
       
        [self createSubView];
    }
    return self;
}


- (void)createSubView {
    
    self.buttonForDowLod = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonForDowLod setImage:[UIImage imageNamed:@"iconfont-xiazai-8"] forState:UIControlStateNormal];
    [self.buttonForDowLod addTarget:self action:@selector(DowLodAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.buttonForDowLod];
    
    self.buttonForShare = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonForShare setImage:[UIImage imageNamed:@"iconfont-fenxiang"] forState:UIControlStateNormal];

    [self addSubview:self.buttonForShare];
    
    self.labelForName = [[UILabel alloc] init];
    self.labelForName.textAlignment = 1;
    self.labelForName.font = [UIFont systemFontOfSize:20];
    [self addSubview:self.labelForName];
    
    self.labelForPlayCount = [[UILabel alloc] init];
    [self addSubview:self.labelForPlayCount];
    self.labelForPlayCount.textColor = [UIColor grayColor];
    
    self.labelForCommentCount = [[UILabel alloc] init];
    [self addSubview:self.labelForCommentCount];
    self.labelForCommentCount.textColor = [UIColor grayColor];
    
    self.imageViewForPlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-play-outline"]];
    [self addSubview:self.imageViewForPlay];
    
    self.imageViewForComment = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-pinglun"]];
    [self addSubview:self.imageViewForComment];
}

- (void)DowLodAction:(UIButton *)button {
    
    NSLog(@"弹窗, 显示下载类型");
}

- (void)layoutSubviews {
    
    self.buttonForDowLod.frame = CGRectMake(self.frame.size.width / 1.3, self.frame.size.height / 1.5, 30, 30);
    self.buttonForShare.frame = CGRectMake(self.frame.size.width / 1.1, self.frame.size.height / 1.5, 30, 30);
    
    self.labelForName.frame = CGRectMake(self.frame.size.width / 14, self.frame.size.height / 3.5, self.frame.size.width / 1.5, self.frame.size.height / 4);
    
    self.imageViewForPlay.frame = CGRectMake(self.frame.size.width / 12, self.frame.size.height / 1.7, 30, 30);
    
    self.labelForPlayCount.frame = CGRectMake(self.frame.size.width / 6, self.frame.size.height / 1.7, 40, 25);
    
    self.imageViewForComment.frame = CGRectMake(self.frame.size.width / 3.5, self.frame.size.height / 1.7, 30, 30);
    
    self.labelForCommentCount.frame = CGRectMake(self.frame.size.width / 2.7, self.frame.size.height / 1.7, 40, 25);

}

- (void)passModel:(XCModelForMVHeader *)model {
    
    self.labelForName.text = model.videoName;
    self.labelForPlayCount.text = [model.pickCount stringValue];
    self.labelForCommentCount.text = [model.bulletCount stringValue];
}


@end
